package com.wrial.kind.tree;
/*
 * @Author  Wrial
 * @Date Created in 17:00 2020/8/9
 * @Description
 */

public class MirrorTree {
    /**
     * 递归从下到上进行左右翻转
     * @param root
     * @return
     */
    public TreeNode mirrorTree(TreeNode root) {
        if (root == null) return null;
        TreeNode left = mirrorTree(root.left);
        TreeNode right = mirrorTree(root.right);
        root.left = right;
        root.right = left;
        return root;
    }

    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

}
